Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Changes the chanced output logic to be more deterministic instead of purely relying on pseudo-rng.
Adds the ability to use fractions as a chance.
Implementation Details
Chances are made deterministic by caching failed chances when rolling to add to it on the next roll. A role is considered successful if the chance + cached chance exceeds the entry's max chance. The OR chance logic also has the added behavior of succeeding several times if the chance is many times over the max chance.
Cached chances are stored in ARL as a Object2Int map, and is serialized to NBT. If a chanced entry is rolled for the first time, a random number between
[0,entry.getMaxChance())
is returned, acting as an initial offset. The cache is cleared when a new recipe is found and is different from the previous recipe.added extra methods to RecipeBuilder to interpret a string as a fractional chance, allowing for irrational fractions to be used as chances. the fraction is split into numerator and denominator, and then scaled up to the max chance (10,000) to make adding chance boosts easier.
Outcome
death to rng